/*
	Title: 01_Figure5.do
	Paper: Brauning, Ivashina, Ozdagli (2025)
	Description: Figure 5 - Investment response to (latent) covenant violation
*/

/*------------------------------------------------------------------------------
								  Figure 5	
------------------------------------------------------------------------------*/
// Import Figure 5 data
use "$data_path/Figure5.dta", clear

// Confidence interval (%)
local ci = 90 

// Create Figure 5A
set scheme s1color
serrbar mean_capex_capital_ratio se_capex_capital_ratio q_first_covenant_break if type == "Maintenance", ///
		ylabel(2(2)10, labsize(small) grid) xlabel(-4(1)4, labsize(small)) /// 
		yscale(r(2(2)10)) ///
		mvopts(mcolor(navy) mlcolor(navy)) /// 
		lcolor(navy) /// 
		xtitle(" " "Quarters since maintenance covenant violation", size(small)) ///
		ytitle("Investment (% of capital)" " " , size(small)) ///
		graphregion(color(white)) scale(`=-1*invnormal((100-`ci')/200)') ///
		plotregion(style(none)) ///
		xline(0, lp(dash) lc(gray)) ///
		name(Figure5A, replace)
		
graph export "$figures_path/Figure5A.png", replace 		
		
// Create Figure 5B
set scheme s1color
serrbar mean_capex_capital_ratio se_capex_capital_ratio q_first_covenant_break if type == "Incurrence", ///
		ylabel(2(2)10, labsize(small) grid) xlabel(-4(1)4, labsize(small)) /// 
		yscale(r(2(2)10)) ///
		mvopts(mcolor(navy) mlcolor(navy)) /// 
		lcolor(navy) /// 
		xtitle(" " "Quarters since incurrence covenant violation", size(small)) ///
		ytitle("Investment (% of capital)" " ", size(small)) ///
		graphregion(color(white)) scale(`=-1*invnormal((100-`ci')/200)') ///
		plotregion(style(none)) ///
		xline(0, lp(dash) lc(gray)) ///
		name(Figure5B, replace)
		
graph export "$figures_path/Figure5B.png", replace 		